﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.AgentSys.SvrMgr
{
    public partial class AgentQltyPartsNeedStockUpdate : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.修改 };
            }
        }
        protected override string DWZRef
        {
            get { return "AgentQltyPartsNeedStockList"; }
        }

        #region
        /// <summary>
        /// 需要修改的ID
        /// </summary>
        protected int ID
        {
            get
            {
                return GetRequestValue<int>("ID");
            }
        }

        protected int QltyId {
            get {
                return GetRequestValue<int>("QltyId",0);
            }
        }

        private AgentQltyInfo _objM;
        protected AgentQltyInfo objM
        {
            get
            {
                if (_objM == null)
                    _objM = AgentQltyController.GetByQltyId(QltyId);
                return _objM;
                //OMenuController.ge
            }
        }

        private AgentQltyPartsInfo _obj=null;
        protected AgentQltyPartsInfo obj
        {
            get
            {
                if (_obj == null)
                {
                    List<AgentQltyPartsInfo> list = AgentQltyController.GetAllPartsByQltyId(QltyId);
                    _obj= list.Find(e => e.ID == ID);
                    //_obj = AgentQltyController.GetAllPartsByQltyId(QltyId);
                }
                return _obj;
                //OMenuController.ge
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "updateinstock")
            {
                addmenu();

            }

        }

        protected void addmenu()
        {
            //bool InStock = base.User.IsSuperAdmin ? GetRequestValue<bool>("InStock", true) : true;
            DateTime InDate = GetRequestValue<DateTime>("InDate", DateTime.Now);
            decimal InQuantity = GetRequestValue<decimal>("InQuantity", 0m);
            string InOrderNum = GetRequestValue<string>("InOrderNum", "");
            string InRemark = GetRequestValue<string>("InRemark", "");
            decimal InWuPan = GetRequestValue<decimal>("InWuPan", 0m);
            bool IsPan = GetRequestValue<bool>("IsPan", false);
            int InGuiFan = GetRequestValue<int>("InGuiFan", 0);
            string GoTrack = GetRequestValue<string>("GoTrack", "");
            string GOTrackDate = GetRequestValue<string>("GOTrackDate", "");

            //if (InQuantity > 0)
            //    InStock = true;

            if (AgentQltyController.UpdateInStock(QltyId,ID, InDate, InQuantity, InOrderNum, InRemark, InWuPan, IsPan, InGuiFan, GoTrack, GOTrackDate))
            {
               // AddLog(Permission.修改, obj);
                SuccessJson("修改成功", "");
            }
            else
                ErrorJson("修改失败", "");


        }
    }
}